package cn.by.wms.service;

import cn.by.wms.dao.ProductDao;
import cn.by.wms.entity.Product;
import cn.by.wms.entity.ProductQuery;


import cn.smart.core.util.UserSessionContext;
import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class ProductService {

    @Autowired
    private ProductDao productDao;


    public List<Product> select(ProductQuery query){

       log.debug("有人访问了ProductService.select");
        Thread thread = new Thread(() -> {
            log.debug("thread");
        });
        thread.start();

       // BizException.throwException(ExceptionEnum.BAD_REQUEST.getCode(),ExceptionEnum.BAD_REQUEST.getMessage());

        return productDao.select(query);
    }

    public Integer insert(Product product) {
        //product.setLastUpdateBy(UserSessionContext.get().getNickName());
        return productDao.insert(product);
    }

    public Integer update(Product product) {
        //product.setLastUpdateBy(UserSessionContext.get().getNickName());
        return productDao.update(product);
    }

    public Integer delete(Integer id) {
        return productDao.delete(id);
    }
}
